﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using Model;
namespace DAL
{
    public class UserServer
    {
        public static DataSet selectAllBooks()
        {
            string sql = " select * from bookinfo order by id desc";
            return SQLHELPER.ExecuteDataSet(sql);
        }
        public static object addBook(bookinfo bi)
        {
            return SQLHELPER.ExecuteNonQuery("  insert into bookinfo (title,descript,booktype,price)values('" + bi.Title + "','" + bi.Decsript + "','" + bi.Booktype + "',' "+ bi.Price+"')");
        }
        //根据id查找book
        public static DataSet selectBook(int id)
        {
            return SQLHELPER.ExecuteDataSet("  select [title],[descript],[booktype],[price] from bookinfo where id='" + id + "'");

        }
        //更新书籍信息
         public static  object updateBook(bookinfo bi)
        {
            return  SQLHELPER.ExecuteNonQuery("  update bookinfo set title='" + bi.Title + "',descript='" + bi.Decsript + "',booktype='" + bi.Booktype+ "',price='" + bi.Price+"' where id='" + bi.Id+"'");
        }
        //删除书籍
        public static object deleteByid(int id)
        {
            return SQLHELPER.ExecuteNonQuery("  delete from bookinfo where id='" + id + "'");
        }
    }
}
